package CtrLag;
import ModelLag.*;
import java.util.ArrayList;

/**
 * The PersonCtrl class is used to control the Person class and PersonContainer class by calling their methods
 * 
 * @author (Lackshan, Mikkel, Nick, patrick, Simon, Yousef) 
 * @project (Tema design)
 * @version (2014.11.04)
 */
public class PersonCtr
{
    private PersonContainer pCon;

    /**
     * Constructor for objects of class PersonCtrl
     */
    public PersonCtr(){
        pCon = PersonContainer.getInstance();
    }
    
    /**
     * This method is used to create and add a person to the PersonContainer class 
     * 
     * @param n is the user input for the new name for the Person Object
     * @param a is the user input for the new address for the Person Object
     * @param z is the user input for the new zip for the Person Object
     * @param c is the user input for the new city for the Person Object
     * @param p is the user input for the new phonenumber for the Person Object 
     */
    public void createPerson(String n, String a, String z, String c, String p){
        Person localPerson = new Person(n,a,z,c,p);
        pCon.addPerson(localPerson);
    }
    
    /**
     * This method is used to update a persons information
     * 
     * @param pers is an Object of class Person
     * @param n is the user input for the new name for the Person Object
     * @param a is the user input for the new address for the Person Object
     * @param z is the user input for the new zip for the Person Object
     * @param c is the user input for the new city for the Person Object
     * @param p is the user input for the new phonenumber for the Person Object 
     * 
     */
    public void updatePerson(Person pers, String n, String a, String z, String c, String p){
        pers.setName(n);
        pers.setAddress(a);
        pers.setZip(z);
        pers.setCity(c);
        pers.setPhone(p);
    }
    
    /**
     * Returns person based on phone 
     * 
     * @Return Person, a person object
     */
    public Person findPerson(String phone){
        Person p = pCon.getPerson(phone);
        return p;
    }
    
    /**
     * This method is used to delete a specified person object using that persons Phone
     * 
     * @param p is the person gotten from pCon by use of Phone
     */
    public void deletePerson(String Phone){
        Person p = pCon.getPerson(Phone);
        pCon.deletePerson(p);
    }
}
